package com.sdry.product.prehangingline.controller;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdry.common.BaseController;
import com.sdry.common.TableDataInfo;
import com.sdry.product.prehangingline.entity.StationMateriel;
import com.sdry.product.prehangingline.service.StationMaterielService;
import com.sdry.product.prod.entity.ProductTwoPaint;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @program: info_sdry
 * @description: 链条绑定表
 * @author: cb
 * @create: 2020-03-02 17:14
 **/
@Controller
@RequestMapping(value = "stationMateriel")
public class StationMaterielController extends BaseController {

    @Autowired
    private StationMaterielService stationMaterielService;

    /**
     * 绑定展示
     * @return
     */
    @RequestMapping(value = "showStationMateriel")
    public String showStationMateriel() {
        return "/product/prod/binding";
    }


    /**
     * 分页查询绑定表
     * @param stationMateriel 绑定表
     * @return TableDataInfo
     */
    @RequestMapping(value = "queryStationMaterielPage")
    @ResponseBody
    public TableDataInfo queryStationMaterielPage(StationMateriel stationMateriel) {
        logger.info("分页查询绑定表  stationMateriel = {} "+ JSONArray.fromObject(stationMateriel));
        QueryWrapper<StationMateriel> queryWrapper = new QueryWrapper<>();
        Page<StationMateriel> page = new Page<>(stationMateriel.getPage(),stationMateriel.getLimit());
        IPage<StationMateriel> stationMaterielIPage = stationMaterielService.page(page, queryWrapper);
        return getDataTable(stationMaterielIPage.getRecords(),stationMaterielIPage.getTotal());
    }

}
